//
//  FFRecvCardCell.m
//  LLWallet
//
//  Created by tt on 2020/12/16.
//

#import "FFRecvCardCell.h"
#import "LBXScanNative.h"
@implementation FFRecvCardModel

- (Class)cell {
    return FFRecvCardCell.class;
}

- (NSNumber *)showArrow {
    return @(YES);
}

@end

#define headerHeight 64.0f
#define barcodeHeight 140.0f

@interface FFRecvCardCell ()

@property(nonatomic,strong) FFQRCodeBoxView *qrcodeBoxView; // 用于生成图片

@property(nonatomic,strong) FFRecvCardModel *model;

@property(nonatomic,strong) UIView *boxView;

@property(nonatomic,strong) UIButton *moreBtn;

@property(nonatomic,strong) UIImageView *recvPayIcon;
@property(nonatomic,strong) UILabel *titleLbl;

@property(nonatomic,strong) UIView *bodyView;

@property(nonatomic,strong) UILabel *tipLbl;


@property(nonatomic,strong) UIImageView *qrcodeView;

@property(nonatomic,strong) UIView *footerLineView;

@property(nonatomic,strong) UIView *footerView;

// 记录
@property(nonatomic,strong) UIImageView *recordIcon; // 记录icon
@property(nonatomic,strong) UILabel *recordTitleLbl; // 记录标题

@property(nonatomic,strong) WKUserAvatar *avatarView; // 个人头像

@property(nonatomic,strong) UIButton *setMoneyBtn; // 设置金额
@property(nonatomic,strong) UIButton *saveQRCodeBtn; // 保存二维码
@property(nonatomic,strong) UIView *shortLineView;

@property(nonatomic,strong) UIView *operateBox;

@property(nonatomic,strong) UIActivityIndicatorView *indicatorView;

@property(nonatomic,strong) UILabel *amountLbl;
@property(nonatomic,strong) UILabel *remarkLbl;

@end

#define amountFontSize 36.0f
#define remarkFontSize 16.0f

@implementation FFRecvCardCell

+ (CGSize)sizeForModel:(FFRecvCardModel *)model {
    CGFloat height = 0.0f;
    if(model.amount>0) {
        height = amountFontSize+40.0f;
    }
    if(model.remark && ![model.remark isEqualToString:@""]) {
        height += remarkFontSize + 20.0f;
    }
    return CGSizeMake(WKScreenWidth,500.0f + height);
}

- (void)setupUI {
    [super setupUI];
    self.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.boxView];
    
    
//    [self.boxView addSubview:self.moreBtn];
    
    [self.boxView addSubview:self.recvPayIcon];
    [self.boxView addSubview:self.titleLbl];
    
    [self.boxView addSubview:self.bodyView];
    [self.bodyView addSubview:self.tipLbl];
    [self.bodyView addSubview:self.qrcodeView];
    [self.bodyView addSubview:self.operateBox];
    
    [self.operateBox addSubview:self.setMoneyBtn];
    [self.operateBox addSubview:self.shortLineView];
    [self.operateBox addSubview:self.saveQRCodeBtn];

    [self.qrcodeView addSubview:self.avatarView];
    [self.qrcodeView addSubview:self.indicatorView];
    
    [self.bodyView addSubview:self.footerLineView];
    [self.bodyView addSubview:self.footerView];
    [self.bodyView addSubview:self.amountLbl];
    [self.bodyView addSubview:self.remarkLbl];
    
    [self.footerView addSubview:self.recordIcon];
    [self.footerView addSubview:self.recordTitleLbl];
    
    
    [self qrcodeBoxView];
    
    
}

- (void)refresh:(FFRecvCardModel *)model {
    [super refresh:model];
    self.model = model;
    self.qrcodeView.image = nil;
    self.indicatorView.hidden = YES;
    [self.indicatorView stopAnimating];
    self.avatarView.hidden = NO;
    if(model.loading) {
        self.avatarView.hidden = YES;
        self.indicatorView.hidden = NO;
        [self.indicatorView startAnimating];
    }else{
        self.qrcodeView.image =  [LBXScanNative createQRWithString:model.qrcode?:@"" QRSize:CGSizeMake(self.qrcodeView.lim_size.width*2, self.qrcodeView.lim_size.height*2)];
    }
    self.avatarView.url = [WKAvatarUtil getAvatar:[WKApp shared].loginInfo.uid];
    
    self.amountLbl.hidden = YES;
    self.remarkLbl.hidden = YES;
    if([self hasAmount]){
        self.amountLbl.hidden = NO;
        self.amountLbl.text = [NSString stringWithFormat:@"¥%@", [WKMoneyUtil penny2YuanFormat:@(model.amount)]];
        [self.amountLbl sizeToFit];
    }
    if([self hasRemark]) {
        self.remarkLbl.hidden = NO;
        self.remarkLbl.text = self.model.remark;
        [self.remarkLbl sizeToFit];
    }
    if([self hasAmount]) {
        [self.setMoneyBtn setTitle:LLang(@"清除金额") forState:UIControlStateNormal];
    }else{
        [self.setMoneyBtn setTitle:LLang(@"设置金额") forState:UIControlStateNormal];
    }
    [self.setMoneyBtn sizeToFit];
    
    self.qrcodeBoxView.amount = model.amount;
    self.qrcodeBoxView.remark = model.remark;
    self.qrcodeBoxView.qrcodeImg = self.qrcodeView.image;
    self.qrcodeBoxView.name = [WKApp shared].loginInfo.extra[@"name"];
    [self.qrcodeBoxView layoutSubviews];
    
}

-(BOOL) hasAmount {
    return  self.model.amount>0;
}

-(BOOL) hasRemark {
    if(self.model.remark && ![self.model.remark isEqualToString:@""]) {
        return true;
    }
    return false;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.boxView.lim_left = 10.0f;
    self.boxView.lim_height = self.contentView.lim_height;
    self.boxView.lim_width = self.contentView.lim_width - self.boxView.lim_left*2;
    self.boxView.lim_centerX_parent = self.contentView;
    
    if(self.model.bottomNoCorner) {
        [self setOnlyTopCorner];
    }else{
        [self setAllCorner];
    }
    
    self.moreBtn.lim_left = self.boxView.lim_width - self.moreBtn.lim_width - 15.0f;
    self.moreBtn.lim_top = headerHeight/2.0f - self.moreBtn.lim_height/2.0f;
    
    self.recvPayIcon.lim_left = 15.0f;
    self.recvPayIcon.lim_top = headerHeight/2.0f - self.recvPayIcon.lim_height/2.0f;
    
    self.titleLbl.lim_top =  headerHeight/2.0f - self.titleLbl.lim_height/2.0f;
    self.titleLbl.lim_left = self.recvPayIcon.lim_right + 10.0f;
    
    self.bodyView.lim_top = headerHeight;
    self.bodyView.lim_height = self.boxView.lim_height - headerHeight;
    self.bodyView.lim_width = self.boxView.lim_width;
   
    self.tipLbl.lim_top = 20.0f;
    self.tipLbl.lim_centerX_parent = self.bodyView;
    
    CGFloat qrcodeTopSpace = 0.0f;
    if([self hasAmount]) {
        self.amountLbl.lim_top = self.tipLbl.lim_bottom + 20.0f;
        self.amountLbl.lim_centerX_parent = self.bodyView;
        qrcodeTopSpace = self.amountLbl.lim_bottom + 20.0f;
    }else{
        qrcodeTopSpace = self.tipLbl.lim_bottom+20.0f;
    }
    if([self hasRemark]) {
        self.remarkLbl.lim_top = self.amountLbl.lim_bottom + 10.0f;
        self.remarkLbl.lim_centerX_parent = self.bodyView;
        qrcodeTopSpace = self.remarkLbl.lim_bottom + 20.0f;
    }
   
    
    self.qrcodeView.lim_top = qrcodeTopSpace;
    self.qrcodeView.lim_centerX_parent = self.bodyView;
    
    if(self.model.loading) {
        self.indicatorView.lim_size = self.qrcodeView.lim_size;
    }
    
    self.operateBox.lim_top = self.qrcodeView.lim_bottom + 10.0f;
    self.operateBox.lim_width = self.bodyView.lim_width;
    self.operateBox.lim_height = 60.0f;
    
    CGFloat operateContentSpace = 40.0f;
    
    CGFloat operateContentWidth = self.setMoneyBtn.lim_width + operateContentSpace + self.shortLineView.lim_width + operateContentSpace + self.saveQRCodeBtn.lim_width;
    
    self.setMoneyBtn.lim_centerY_parent = self.operateBox;
    self.setMoneyBtn.lim_left = self.operateBox.lim_width/2.0f - operateContentWidth/2.0f;
    
    self.shortLineView.lim_centerY_parent = self.operateBox;
    self.shortLineView.lim_left = self.setMoneyBtn.lim_right + operateContentSpace;
    
    self.saveQRCodeBtn.lim_left = self.shortLineView.lim_right + 30.0f;
    self.saveQRCodeBtn.lim_centerY_parent = self.operateBox;
    
    self.footerView.lim_height = headerHeight;
    self.footerView.lim_width = self.bodyView.lim_width;
    self.footerView.lim_top = self.bodyView.lim_height - self.footerView.lim_height;
    
    self.footerLineView.lim_left = 20.0f;
    self.footerLineView.lim_width = self.bodyView.lim_width - 20.0f*2;
    self.footerLineView.lim_top = self.footerView.lim_top;
    
    self.recordIcon.lim_left = self.footerLineView.lim_left;
    self.recordIcon.lim_centerY_parent = self.footerView;
    
    self.recordTitleLbl.lim_left = self.recordIcon.lim_right + 10.0f;
    self.recordTitleLbl.lim_centerY_parent = self.footerView;
    
    self.avatarView.lim_centerX_parent = self.qrcodeView;
    self.avatarView.lim_centerY_parent = self.qrcodeView;
    
    self.arrowImgView.lim_left = WKScreenWidth - 40.0f;
    self.arrowImgView.lim_top = (self.footerView.lim_top+headerHeight) + (headerHeight/2.0f - self.arrowImgView.lim_height/2.0f);
    
    
}

-(void) setAllCorner {
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.boxView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(8, 8)];
     CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
     maskLayer.frame = self.boxView.bounds;
     maskLayer.path = maskPath.CGPath;
     self.boxView.layer.mask = maskLayer;
}

-(void) setOnlyTopCorner {
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.boxView.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(8, 8)];
     CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
     maskLayer.frame = self.boxView.bounds;
     maskLayer.path = maskPath.CGPath;
     self.boxView.layer.mask = maskLayer;
}


- (UIView *)boxView {
    if(!_boxView) {
        _boxView = [[UIView alloc] init];
        _boxView.backgroundColor = [UIColor colorWithRed:249.0f/255.0f green:249.0f/255.0f blue:249.0f/255.0f alpha:1.0f];
    }
    return _boxView;
}

- (UIImageView *)recvPayIcon {
    if(!_recvPayIcon) {
        _recvPayIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 24.0f, 24.0f)];
        _recvPayIcon.image = [self imageName:@"recv"];
    }
    return _recvPayIcon;
}

- (UILabel *)titleLbl {
    if(!_titleLbl) {
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.textColor = [UIColor colorWithRed:230.0f/255.0f green:183.0f/255.0f blue:62.0f/255.0f alpha:1.0f];
        _titleLbl.font = [[WKApp shared].config appFontOfSize:17.0f];
        _titleLbl.text = LLang(@"二维码收款");
        [_titleLbl sizeToFit];
    }
    return _titleLbl;
}

- (UIView *)bodyView {
    if(!_bodyView) {
        _bodyView = [[UIView alloc] init];
        _bodyView.backgroundColor = [UIColor whiteColor];
    }
    return _bodyView;
}

- (UIImageView *)qrcodeView {
    if(!_qrcodeView) {
        _qrcodeView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 240.0f, 240.0f)];
    }
    return _qrcodeView;
}


- (UIView *)footerView {
    if(!_footerView) {
        _footerView = [[UIView alloc] init];
        _footerView.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(footerPressed)];
        [_footerView addGestureRecognizer:tap];
    }
    return _footerView;
}

-(void) footerPressed {
    if(self.model.onRecord) {
        self.model.onRecord();
    }
}

- (UIView *)footerLineView {
    if(!_footerLineView) {
        _footerLineView = [[UIView alloc] init];
        _footerLineView.backgroundColor = [UIColor colorWithRed:249.0f/255.0f green:249.0f/255.0f blue:249.0f/255.0f alpha:1.0f];
        _footerLineView.lim_height = 1.0f;
    }
    return _footerLineView;
}


- (UIImageView *)recordIcon {
    if(!_recordIcon) {
        _recordIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 24.0f, 24.0f)];
        _recordIcon.image = [self imageName:@"record"];
    }
    return _recordIcon;
}

- (UILabel *)recordTitleLbl {
    if(!_recordTitleLbl) {
        _recordTitleLbl = [[UILabel alloc] init];
        _recordTitleLbl.text = LLang(@"收款记录");
        _recordTitleLbl.font = [[WKApp shared].config appFontOfSize:16.0f];
        _recordTitleLbl.textColor = [UIColor blackColor];
        [_recordTitleLbl sizeToFit];
    }
    return _recordTitleLbl;
}


- (UIButton *)moreBtn {
    if(!_moreBtn) {
        _moreBtn = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
        [_moreBtn setImage:[self imageName:@"more"] forState:UIControlStateNormal];
    }
    return _moreBtn;
}

- (UILabel *)tipLbl {
    if(!_tipLbl) {
        _tipLbl = [[UILabel alloc] init];
        _tipLbl.text = LLang(@"无需加好友，扫二维码向我付钱");
        _tipLbl.font = [[WKApp shared].config appFontOfSize:16.0f];
        _tipLbl.textColor = [UIColor colorWithRed:83.0f/255.0f green:83.0f/255.0f blue:83.0f/255.0f alpha:1.0f];
        [_tipLbl sizeToFit];
    }
    return _tipLbl;
}

- (WKUserAvatar *)avatarView {
    if(!_avatarView) {
        _avatarView = [[WKUserAvatar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [WKApp shared].config.messageListAvatarSize.width,  [WKApp shared].config.messageListAvatarSize.height)];
    }
    return _avatarView;
}

- (UIButton *)setMoneyBtn {
    if(!_setMoneyBtn) {
        _setMoneyBtn = [[UIButton alloc] init];
        [_setMoneyBtn setTitleColor:[UIColor colorWithRed:90.0f/255.0f green:107.0f/255.0f blue:145.0f/255.0f alpha:1.0f] forState:UIControlStateNormal];
        [_setMoneyBtn.titleLabel setFont:[[WKApp shared].config appFontOfSize:16.0f]];
        [_setMoneyBtn addTarget:self action:@selector(setMoneyPressed) forControlEvents:UIControlEventTouchUpInside];
    }
    return _setMoneyBtn;
}
- (UILabel *)amountLbl {
    if(!_amountLbl) {
        _amountLbl = [[UILabel alloc] init];
        _amountLbl.font = [[WKApp shared].config appFontOfSizeSemibold:amountFontSize];
    }
    return _amountLbl;
}

- (UILabel *)remarkLbl {
    if(!_remarkLbl) {
        _remarkLbl = [[UILabel alloc] init];
        _remarkLbl.font = [[WKApp shared].config appFontOfSize:remarkFontSize];
    }
    return _remarkLbl;
}

-(void) setMoneyPressed {
    if(self.model.onSetAmount) {
        self.model.onSetAmount();
    }
}

- (UIView *)shortLineView {
    if(!_shortLineView) {
        _shortLineView = [[UIView alloc] init];
        _shortLineView.lim_height = 20.0f;
        _shortLineView.lim_width = 1.0f;
        _shortLineView.backgroundColor = [UIColor colorWithRed:240.0f/255.0f green:240.0f/255.0f blue:240.0f/255.0f alpha:1.0f];
    }
    return _shortLineView;
}

- (UIButton *)saveQRCodeBtn {
    if(!_saveQRCodeBtn) {
        _saveQRCodeBtn = [[UIButton alloc] init];
        [_saveQRCodeBtn setTitle:LLang(@"保存收款码") forState:UIControlStateNormal];
        [_saveQRCodeBtn setTitleColor:[UIColor colorWithRed:90.0f/255.0f green:107.0f/255.0f blue:145.0f/255.0f alpha:1.0f] forState:UIControlStateNormal];
        [_saveQRCodeBtn.titleLabel setFont:[[WKApp shared].config appFontOfSize:16.0f]];
        [_saveQRCodeBtn sizeToFit];
        [_saveQRCodeBtn addTarget:self action:@selector(saveQRCodePressed) forControlEvents:UIControlEventTouchUpInside];
    }
    return _saveQRCodeBtn;
}
-(void) saveQRCodePressed {
    [self saveImageView];
}

- (UIView *)operateBox {
    if(!_operateBox) {
        _operateBox = [[UIView alloc] init];
    }
    return _operateBox;
}
-(UIActivityIndicatorView*) indicatorView {
    if(!_indicatorView) {
        _indicatorView = [[UIActivityIndicatorView alloc] init];
    }
    return _indicatorView;
}

- (FFQRCodeBoxView *)qrcodeBoxView {
    if(!_qrcodeBoxView) {
        _qrcodeBoxView = [[FFQRCodeBoxView alloc] init];
    }
    return _qrcodeBoxView;
}

//截屏分享  传入想截屏的view(也可以是controller
//webview只能截当前屏幕-_-`,用其他的方法)
- (void)saveImageView {
  UIGraphicsBeginImageContextWithOptions(self.qrcodeBoxView.frame.size, NO, 0);
  CGContextRef ctx = UIGraphicsGetCurrentContext();
  [self.qrcodeBoxView.layer renderInContext:ctx];
  // 这个是要分享图片的样式(自定义的)
  UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
  //保存到本地相机
  UIImageWriteToSavedPhotosAlbum(
      newImage, self, @selector(image:didFinishSavingWithError:contextInfo:),
      nil);
}
//保存相片的回调方法
- (void)image:(UIImage *)image
    didFinishSavingWithError:(NSError *)error
                 contextInfo:(void *)contextInfo {
  if (error) {
      [self showMsg:LLang(@"保存图片失败！请检查是否开启权限!")];
  } else {
    [self showMsg:LLang(@"保存成功！")];
  }
}


-(UIImage*) imageName:(NSString*)name {
    return [[WKApp shared] loadImage:name moduleID:@"LLWallet"];
}

@end




@interface FFQRCodeBoxView ()

@property(nonatomic,strong) UILabel *titleLbl;

@property(nonatomic,strong) UIView *qrcodeBoxView;
@property(nonatomic,strong) UIImageView *qrcodeImgView;
@property(nonatomic,strong) UILabel *remarkLbl;
@property(nonatomic,strong) UILabel *amountLbl;
@property(nonatomic,strong) WKUserAvatar *avatarView;

@property(nonatomic,strong) UILabel *nameLbl;

@property(nonatomic,strong) UIView *footerView;
@property(nonatomic,strong) UIImageView *iconImgView;
@property(nonatomic,strong) UILabel *footerTitleLbl;



@end

@implementation FFQRCodeBoxView

- (instancetype)init
{
    self = [super initWithFrame:CGRectMake(0.0f, 0.0f, WKScreenWidth, 500.0f)];
    if (self) {
        self.backgroundColor = [WKApp shared].config.themeColor;
        [self setupUI];
    }
    return self;
}

- (void)setQrcodeImg:(UIImage *)qrcodeImg {
    self.qrcodeImgView.image = qrcodeImg;
}

- (void)setAmount:(NSInteger)amount {
    _amount = amount;
    if(amount>0) {
        self.amountLbl.hidden = NO;
        self.amountLbl.text = [NSString stringWithFormat:@"¥%@",[WKMoneyUtil penny2YuanFormat:@(amount)]];
    }else{
        self.amountLbl.text = @"";
        self.amountLbl.hidden = YES;
    }
   
    [self.amountLbl sizeToFit];
}

- (void)setRemark:(NSString *)remark {
    _remark = remark;
    if(remark && ![remark isEqualToString:@""]) {
        self.remarkLbl.text = remark;
        self.remarkLbl.hidden = NO;
    }else{
        self.remarkLbl.text = @"";
        self.remarkLbl.hidden = YES;
    }
    
    [self.remarkLbl sizeToFit];
}

- (void)setName:(NSString *)name {
    self.nameLbl.text = name;
    [self.nameLbl sizeToFit];
}

-(void) setupUI {
    [self addSubview:self.titleLbl];
    
    [self addSubview:self.qrcodeBoxView];
    [self.qrcodeBoxView addSubview:self.qrcodeImgView];
    [self.qrcodeImgView addSubview:self.avatarView];
    
    [self.qrcodeBoxView addSubview:self.amountLbl];
    [self.qrcodeBoxView addSubview:self.remarkLbl];
    
    [self addSubview:self.nameLbl];
    
    [self addSubview:self.footerView];
    [self.footerView addSubview:self.iconImgView];
    [self.footerView addSubview:self.footerTitleLbl];
}

-(BOOL) hasAmount {
    return _amount>0;
}

-(BOOL) hasRemark {
    return _remark && ![_remark isEqualToString:@""];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.titleLbl.lim_top = 20.0f;
    self.titleLbl.lim_centerX_parent = self;
    
    self.qrcodeBoxView.lim_top = self.titleLbl.lim_bottom + 20.0f;
    self.qrcodeBoxView.lim_height = self.qrcodeBoxView.lim_width;
    self.qrcodeBoxView.lim_centerX_parent = self;
    if([self hasAmount]) {
        self.qrcodeBoxView.lim_height += 30.0f;
    }
    if([self hasRemark]) {
        self.qrcodeBoxView.lim_height += 20.0f;
    }
    
    self.amountLbl.lim_top = 10.0f;
    self.amountLbl.lim_centerX_parent = self.qrcodeBoxView;
    
    self.remarkLbl.lim_top = self.amountLbl.lim_bottom + 2.0f;
    self.remarkLbl.lim_centerX_parent = self.qrcodeBoxView;
    
    self.qrcodeImgView.lim_left = 10.0f;
    self.qrcodeImgView.lim_width = self.qrcodeBoxView.lim_width - self.qrcodeImgView.lim_left*2;
    self.qrcodeImgView.lim_height = self.qrcodeImgView.lim_width;
    self.qrcodeImgView.lim_top = self.qrcodeBoxView.lim_height - self.qrcodeImgView.lim_height - self.qrcodeImgView.lim_left;
    
    self.avatarView.lim_centerX_parent = self.qrcodeImgView;
    self.avatarView.lim_centerY_parent = self.qrcodeImgView;
    
    self.nameLbl.lim_top = self.qrcodeBoxView.lim_bottom + 20.0f;
    self.nameLbl.lim_centerX_parent = self;
    
    self.footerView.lim_top = self.lim_height - self.footerView.lim_height;
    
    CGFloat iconRightSpace = 15.0f;
    CGFloat iconAndFooterTitleWidth = self.footerTitleLbl.lim_width + iconRightSpace + self.iconImgView.lim_width;
    
    self.iconImgView.lim_left = self.footerView.lim_width/2.0f - iconAndFooterTitleWidth/2.0f;
    self.iconImgView.lim_centerY_parent  =self.footerView;
    
    self.footerTitleLbl.lim_left = self.iconImgView.lim_right + iconRightSpace;
    self.footerTitleLbl.lim_centerY_parent = self.footerView;
    
}

- (UILabel *)titleLbl {
    if(!_titleLbl) {
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.font = [[WKApp shared].config appFontOfSize:26.0f];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:LLang(@"推荐使用")];
        NSString *appName = [NSString stringWithFormat:LLang(@"%@支付"),[WKApp shared].config.appName];
        NSRange range = NSMakeRange(str.length, appName.length);
        [str appendAttributedString:[[NSAttributedString alloc] initWithString:appName]];
        [str addAttribute:NSFontAttributeName value:[[WKApp shared].config appFontOfSizeSemibold:26.0f] range:range];
        _titleLbl.attributedText = str;
        _titleLbl.textColor = [UIColor whiteColor];
        [_titleLbl sizeToFit];
    }
    return _titleLbl;
}

- (UIView *)qrcodeBoxView {
    if(!_qrcodeBoxView){
        _qrcodeBoxView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 240.0f, 0.0f)];
        _qrcodeBoxView.backgroundColor = [UIColor whiteColor];
    }
    return _qrcodeBoxView;
}

- (UIImageView *)qrcodeImgView {
    if(!_qrcodeImgView) {
        _qrcodeImgView = [[UIImageView alloc] init];
    }
    return _qrcodeImgView;
}

- (UILabel *)amountLbl {
    if(!_amountLbl) {
        _amountLbl = [[UILabel alloc] init];
        _amountLbl.font = [[WKApp shared].config appFontOfSizeSemibold:18.0f];
        _amountLbl.textColor = [UIColor blackColor];
    }
    return _amountLbl;
}

- (UILabel *)remarkLbl {
    if(!_remarkLbl) {
        _remarkLbl = [[UILabel alloc] init];
        _remarkLbl.textColor = [UIColor colorWithRed:153.0f/255.0f green:153.0f/255.0f blue:153.0f/255.0f alpha:1.0f];
        _remarkLbl.font = [[WKApp shared].config appFontOfSize:12.0f];
    }
    return _remarkLbl;
}

- (UILabel *)nameLbl {
    if(!_nameLbl) {
        _nameLbl = [[UILabel alloc] init];
        _nameLbl.textColor = [UIColor whiteColor];
        _nameLbl.font = [[WKApp shared].config appFontOfSizeMedium:20.0f];
    }
    return _nameLbl;
}

- (UIView *)footerView {
    if(!_footerView) {
        _footerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.lim_width, 80.0f)];
        _footerView.backgroundColor = [UIColor whiteColor];
    }
    return _footerView;
}

- (UILabel *)footerTitleLbl {
    if(!_footerTitleLbl) {
        _footerTitleLbl = [[UILabel alloc] init];
        _footerTitleLbl.text = [NSString stringWithFormat:LLang(@"%@支付"),[WKApp shared].config.appName];
        _footerTitleLbl.textColor = [UIColor colorWithRed:49.0f/255.0f green:49.0f/255.0f blue:49.0f/255.0f alpha:1.0f];
        _footerTitleLbl.font = [[WKApp shared].config appFontOfSize:30.0f];
        [_footerTitleLbl sizeToFit];
    }
    return _footerTitleLbl;
}
- (UIImageView *)iconImgView {
    if(!_iconImgView) {
        _iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 48.0f, 48.0f)];
        _iconImgView.image = [self imageName:@"limao_pay"];
    }
    return _iconImgView;
}

- (WKUserAvatar *)avatarView {
    if(!_avatarView) {
        _avatarView = [[WKUserAvatar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 48.0f, 48.0f)];
        _avatarView.url = [WKAvatarUtil getAvatar:[WKApp shared].loginInfo.uid];
    }
    return _avatarView;
}

-(UIImage*) imageName:(NSString*)name {
    return [[WKApp shared] loadImage:name moduleID:@"LLWallet"];
}

@end
